package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.mappers.AnnouncementMapper;
import com.tanhua.model.domain.Announcement;
import com.tanhua.model.vo.PageResult;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class AnnouncementApiImpl implements AnnouncementApi {

    @Autowired
    private AnnouncementMapper announcementMapper;

    @Override
    public PageResult findAnnouncements(Integer page, Integer pageSize) {
        IPage<Announcement> iPage = new Page(page,pageSize);
        IPage<Announcement> pageResult = announcementMapper.selectPage(iPage, null);
        return new PageResult(pageResult.getTotal(),pageSize,pageResult.getPages(),page,pageResult.getRecords());
    }
}
